<?php
namespace Api;

class Factory
{
    
    /**
     * 魔术方法，实现对象的自动创建
     * @param unknown $func
     * @param unknown $parm
     */
    public static function __callstatic($func, $parm)
    {
        $fun = function () use($func, $parm) {
            $objectName = str_replace('create', '', $func);
            $alias = strtolower($objectName);
            $objectName = '\\Api\\Object\\' . $objectName;
            Register::set($alias . '_' . $parm[0], new $objectName($parm[0]));
        };
        $fun();
        \Api\Log::fileLog(date('Y-m-d H:i:s ').'工厂方法:' . $func . '(' . implode(',', $parm) . ')不存在', 'factory/function');
    }
}